import request from '@/utils/request'

// 手机验证登录
export const getmobile = phone => request.get(`/v1_0/sms/codes/${phone}`)

// 用户认证
export const getUser = data => request.post('/v1_0/authorizations', data)

// 个人信息
export const getUsercont = () => request.get('/v1_0/user/profile')

// 用户频道
export const getUserchannels = () => request.get('/v1_0/user/channels')

// 用户关注
export const followAuthor = (authorId, isFollow) => {
  if (isFollow) {
    return request({
      url: '/v1_0/user/followings',
      method: 'post',
      data: { target: authorId }
    })
  } else {
    return request({
      url: '/v1_0/user/followings/' + authorId,
      method: 'delete'
    })
  }
}

// 收藏
export const collAuthor = (authorId, isFollow) => {
  if (isFollow) {
    return request({
      url: '/v1_0/article/collections',
      method: 'post',
      data: { target: authorId }
    })
  } else {
    return request({
      url: '/v1_0/article/collections/' + authorId,
      method: 'delete'
    })
  }
}
